package com.hhw.mocklocationsample;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.SystemClock;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        LocationMockUtils mLocationTestProvider = new LocationMockUtils();
        String permission = "android.permission.ACCESS_MOCK_LOCATION";
        if (ActivityCompat.checkSelfPermission(this,permission) == PackageManager.PERMISSION_GRANTED){
             System.out.println("拥有权限");
        }else{
           ActivityCompat.requestPermissions(this,new String[]{permission},100);
           System.out.println("没有权限");
           return;
       }


        mLocationTestProvider.init(this);
        mLocationTestProvider.enableLocationMock(true);/

        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){
                    mLocationTestProvider.mockLocation(true,116.397128,39.916527,0.01f,1f,(byte) 3);
                    System.out.println("设置定位数据");
                    SystemClock.sleep(1000);
                }
            }
        }).start();

    }
}